//
//  BrandZoneTableViewCell.m
//  FlyGift
//
//  Created by lanou3g on 15/7/15.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "BrandZoneTableViewCell.h"
#import "BrandZoneModel.h"

@implementation BrandZoneTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.859 green:0.832 blue:1.000 alpha:1.000];
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(kP6width(5), kP6width(5), kScreenWidth - kP6width(10), kP6width(260))];
        [view.layer setCornerRadius:kP6width(8)];
        view.layer.masksToBounds = YES;
        view.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:view];
        // Log图片
        self.LogImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kP6width(10), kP6width(10), kP6width(50), kP6width(50))];
        [view addSubview:self.LogImageView];
        // 品牌名称
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(70), kP6width(10), kP6width(220), kP6width(25))];
        self.nameLabel.textColor = [UIColor blackColor];
        self.nameLabel.font = [UIFont fontWithName:@"CourierNewPS-ItalicMT" size:kP6width(15)];
        [view addSubview:self.nameLabel];
        // 品牌简介
        self.desLable = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(70), kP6width(35), kP6width(220), kP6width(25))];
        self.desLable.textColor = [UIColor grayColor];
        self.desLable.font = [UIFont fontWithName:@"CourierNewPS-ItalicMT" size:kP6width(12)];
        [view addSubview:self.desLable];
        // 品牌主页
        self.brandHomeLable = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(300), kP6width(25), kP6width(60), kP6width(20))];
        self.brandHomeLable.textColor = [UIColor grayColor];
        self.brandHomeLable.font = [UIFont fontWithName:@"CourierNewPS-ItalicMT" size:kP6width(12)];
        self.brandHomeLable.text = @"品牌主页〉";
        [view addSubview:self.brandHomeLable];
        // 前4张产品图的底图
        self.imageBottom = [[UIView alloc]initWithFrame:CGRectMake(kP6width(10), kP6width(70), kP6width(175), kP6width(175))];
        [view addSubview:self.imageBottom];
        self.imageViewOne = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kP6width(85), kP6width(85))];
        [self.imageBottom addSubview:self.imageViewOne];
        self.imageViewTwo = [[UIImageView alloc]initWithFrame:CGRectMake(kP6width(90), 0, kP6width(85), kP6width(85))];
        [self.imageBottom addSubview:self.imageViewTwo];
        self.imageViewThree = [[UIImageView alloc]initWithFrame:CGRectMake(0, kP6width(90), kP6width(85), kP6width(85))];
        [self.imageBottom addSubview:self.imageViewThree];
        self.imageViewFour =[[UIImageView alloc]initWithFrame:CGRectMake(kP6width(90), kP6width(90), kP6width(85), kP6width(85))];
        [self.imageBottom addSubview:self.imageViewFour];
        // 第5张产品图
        self.imageViewFive = [[UIImageView alloc]initWithFrame:CGRectMake(kP6width(190), kP6width(70), kP6width(170), kP6width(175))];
        [view addSubview:self.imageViewFive];
    }
    return self;
}

// 设置cell上的内容
- (void)setCellValueWithModel:(BrandZoneModel *)model row:(NSInteger)row
{
    [self.LogImageView sd_setImageWithURL:[NSURL URLWithString:model.icon_url] placeholderImage:[UIImage imageNamed:@"placeHolder@2x.jpg"]];
    self.nameLabel.text = model.name;
    self.desLable.text = model.desc;
    [self.imageViewOne sd_setImageWithURL:[NSURL URLWithString:model.image_urls[0]] placeholderImage:[UIImage imageNamed:@"placeHolder@2x.jpg"]];
    [self.imageViewTwo sd_setImageWithURL:[NSURL URLWithString:model.image_urls[1]] placeholderImage:[UIImage imageNamed:@"placeHolder@2x.jpg"]];
    [self.imageViewThree sd_setImageWithURL:[NSURL URLWithString:model.image_urls[2]] placeholderImage:[UIImage imageNamed:@"placeHolder@2x.jpg"]];
    [self.imageViewFour sd_setImageWithURL:[NSURL URLWithString:model.image_urls[3]] placeholderImage:[UIImage imageNamed:@"placeHolder@2x.jpg"]];
    [self.imageViewFive sd_setImageWithURL:[NSURL URLWithString:model.image_urls[4]] placeholderImage:[UIImage imageNamed:@"placeHolder@2x.jpg"]];
    if (row % 2) {
        self.imageBottom.frame = CGRectMake(kP6width(185), kP6width(70), kP6width(175), kP6width(175));
        self.imageViewFive.frame = CGRectMake(kP6width(10), kP6width(70), kP6width(170), kP6width(175));
    }
}


@end
